package com.solweaver.greetings.async;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;

import org.apache.activemq.command.ActiveMQObjectMessage;
import org.springframework.stereotype.Component;

import com.solweaver.greetings.dto.EmailMessage;

@Component(value="notificationListener")
public class NotificationListener implements MessageListener{

	@Override
	public void onMessage(Message message) {
		System.out.println("In Consuming Messages from Notification Throttler queue");
		ActiveMQObjectMessage activeMQObjectMessage = (ActiveMQObjectMessage) message;
		EmailMessage emailMessage = null;
		try {
			emailMessage = (EmailMessage) activeMQObjectMessage.getObject();
		} catch (JMSException e) {
			e.printStackTrace();
		}
		System.out.println(emailMessage);
	}
}
